//
//  BBConnectingButton.m
//  xNose
//
//  Created by ben smith on 12/09/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "BBConnectingButton.h"
#import "BBNode.h"
#import "BBDefaultController.h"
#import "BBNodeView.h"
#import "BBNodeController.h"


@implementation BBConnectingButton
@synthesize delegate;

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code here.
    }
    return self;
}

- (void)drawRect:(NSRect)rect {	
	// Drawing code here.
	NSBezierPath * round = [NSBezierPath bezierPathWithOvalInRect:NSInsetRect(self.bounds, 1, 1)];
	[[NSColor whiteColor] set];
	[round stroke];
	[[NSColor lightGrayColor] set];
	if (delegate.node.isConnecting) {
		[[BBDefaultController costColor] set];		
	}
	[round fill];
}

-(void)otherMouseDown:(NSEvent*)theEvent
{
	[self mouseDown:theEvent];
}


-(void)otherMouseDragged:(NSEvent*)theEvent
{
	
}


-(void)mouseDown:(NSEvent*)theEvent
{
	[[BBNodeController sharedNodeController] registerConnectionSource:delegate.node];
	[self setNeedsDisplay:YES];
}

-(void)mouseDragged:(NSEvent*)theEvent
{
	
}

-(void)mouseUp:(NSEvent*)theEvent
{
	[self setNeedsDisplay:YES];
}

- (void) dealloc
{
	[delegate release];
	[super dealloc];
}


@end
